# #  版本1 使用python函数实现js功能
#
# import requests
# import base64
#
# info = input("输入发送原始信息")
# # info_base64 = base64.b64encode(info.encode("utf-8"))
# # res = requests.get(f"https://httpbin.org/get?ID=12345&info={info_base64}")
# # print(res.json())
#
# info_upper = info.upper()
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={info_upper}')
# print(res.json())


# ob混淆




# import execjs
#
# info = input("请输入发送信息")
# # 版本2    通过js代码 对info处理
# js_str = """
#         function do_str(str){
#             // 将字符串转换为数组
#             const arr = str.split('');
#
#             // Fisher-Yates 洗牌算法
#             for (let i = arr.length - 1; i > 0; i--) {
#                 const j = Math.floor(Math.random() * (i + 1));
#                 // 交换元素
#                 [arr[i], arr[j]] = [arr[j], arr[i]];
#             }
#
#             // 将数组转换回字符串
#             return arr.join('');
#         }
# """
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('do_str', info)
# print(r)


# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())


# # 版本3 通过js混淆的代码 对info处理
# import requests
# import execjs
#
# info = input("请输入发送信息")
#
# js_str = """
#         (function(_0x297d18,_0x478dbc){var _0x3b18d1=_0x5a5e,_0x1f31ee=_0x297d18();while(!![]){try{var _0x47057f=parseInt(_0x3b18d1(0xa7))/0x1*(parseInt(_0x3b18d1(0xa6))/0x2)+-parseInt(_0x3b18d1(0xa5))/0x3+parseInt(_0x3b18d1(0xa2))/0x4+parseInt(_0x3b18d1(0xac))/0x5*(parseInt(_0x3b18d1(0xa9))/0x6)+-parseInt(_0x3b18d1(0xa8))/0x7*(-parseInt(_0x3b18d1(0xa4))/0x8)+-parseInt(_0x3b18d1(0xaa))/0x9*(-parseInt(_0x3b18d1(0xab))/0xa)+-parseInt(_0x3b18d1(0xa3))/0xb;if(_0x47057f===_0x478dbc)break;else _0x1f31ee['push'](_0x1f31ee['shift']());}catch(_0x2319a6){_0x1f31ee['push'](_0x1f31ee['shift']());}}}(_0x32ec,0xc4d21));function _0x5a5e(_0x1f6c60,_0xc3d625){var _0x32ecd3=_0x32ec();return _0x5a5e=function(_0x5a5e38,_0x31e6ee){_0x5a5e38=_0x5a5e38-0xa2;var _0x28de3b=_0x32ecd3[_0x5a5e38];return _0x28de3b;},_0x5a5e(_0x1f6c60,_0xc3d625);}function _0x32ec(){var _0x2662c6=['12478uGgSgv','36lksIZg','7bMcGdX','4254sbiSBY','50229GezEWT','870XoTkIT','685lkLgKc','helloword','2672704dxZXXV','5813632LkrLkm','4638632COzqre','2161800tTymAz'];_0x32ec=function(){return _0x2662c6;};return _0x32ec();}function hi(_0x588762){var _0xac9aa9=_0x5a5e;return _0xac9aa9(0xad)+_0x588762;}
# """
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('hi', info)
# print(r)
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())


# # 版本4 补环境 对info处理
# import requests
# import execjs
#
# info = input("请输入发送信息")
# # 需要补充window对象
# js_str = """
#         var window = {
#             navigator:{
#                 userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
#             }
#         };
#
#         function _0x5ae7(_0x3e808a, _0x42456c) {
#                 var _0x53e430 = _0x53e4();
#                 return _0x5ae7 = function(_0x5ae7e8, _0x4a9916) {
#                     _0x5ae7e8 = _0x5ae7e8 - 0x14a;
#                     var _0x10e705 = _0x53e430[_0x5ae7e8];
#                     return _0x10e705;
#                 }
#                 ,
#                 _0x5ae7(_0x3e808a, _0x42456c);
#             }
#             function _0x53e4() {
#                 var _0x3d2ea5 = ['33xzUkXV', '232AIVtEC', '6924280oQBQGC', 'navigator', '521272FXnRIN', '1015715DufioH', '1330464vOvRNL', '280567chMfYB', 'userAgent', 'name', '30dekDHH', '35556MyPBAR', '10558692pBpUab', '81RhvtKL'];
#                 _0x53e4 = function() {
#                     return _0x3d2ea5;
#                 }
#                 ;
#                 return _0x53e4();
#             }
#             (function(_0x4959b2, _0x4986f5) {
#                 var _0x547eb6 = _0x5ae7
#                   , _0x3a2da0 = _0x4959b2();
#                 while (!![]) {
#                     try {
#                         var _0x1a74a7 = -parseInt(_0x547eb6(0x14f)) / 0x1 + parseInt(_0x547eb6(0x151)) / 0x2 + -parseInt(_0x547eb6(0x14a)) / 0x3 * (parseInt(_0x547eb6(0x156)) / 0x4) + -parseInt(_0x547eb6(0x150)) / 0x5 * (-parseInt(_0x547eb6(0x155)) / 0x6) + parseInt(_0x547eb6(0x152)) / 0x7 * (-parseInt(_0x547eb6(0x14c)) / 0x8) + -parseInt(_0x547eb6(0x157)) / 0x9 + parseInt(_0x547eb6(0x14d)) / 0xa * (parseInt(_0x547eb6(0x14b)) / 0xb);
#                         if (_0x1a74a7 === _0x4986f5)
#                             break;
#                         else
#                             _0x3a2da0['push'](_0x3a2da0['shift']());
#                     } catch (_0x2d220c) {
#                         _0x3a2da0['push'](_0x3a2da0['shift']());
#                     }
#                 }
#             }(_0x53e4, 0xa17ab));
#
#         function userAgent_btoa(_0x1a3a4f) {
#                 var _0xb62ab1 = _0x5ae7;
#                 return window[_0xb62ab1(0x14e)][_0xb62ab1(0x153)] + btoa(_0xb62ab1(0x154));
#             }
# """
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('userAgent_btoa', info)
# print(r)
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())


# import requests
# import execjs
#
#
# info = input("输入发送原始信息")
# # 通过js 代码 对info处理
#
# js_str = """
#             var window = {
#                 navigator: {
#                     userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
#                 },
#                 document: {
#                     cookie: "csrftoken=1H6tdIUiVRuckeg044kikR8NrLyFYAo5"
#                 }
#             };
#
#             function _0x2b77(_0x20e79e,_0x841523){const _0x3fdbbd=_0x3fdb();return _0x2b77=function(_0x2b7727,_0x3f599a){_0x2b7727=_0x2b7727-0x168;let _0x3a78b4=_0x3fdbbd[_0x2b7727];return _0x3a78b4;},_0x2b77(_0x20e79e,_0x841523);}(function(_0x2f8ec6,_0x1b2d56){const _0x1bf6c6=_0x2b77,_0x3090d0=_0x2f8ec6();while(!![]){try{const _0x42899b=-parseInt(_0x1bf6c6(0x174))/0x1*(-parseInt(_0x1bf6c6(0x176))/0x2)+parseInt(_0x1bf6c6(0x169))/0x3*(parseInt(_0x1bf6c6(0x16f))/0x4)+parseInt(_0x1bf6c6(0x16d))/0x5*(parseInt(_0x1bf6c6(0x16b))/0x6)+parseInt(_0x1bf6c6(0x16c))/0x7*(-parseInt(_0x1bf6c6(0x177))/0x8)+-parseInt(_0x1bf6c6(0x16e))/0x9*(parseInt(_0x1bf6c6(0x168))/0xa)+parseInt(_0x1bf6c6(0x16a))/0xb+-parseInt(_0x1bf6c6(0x170))/0xc*(-parseInt(_0x1bf6c6(0x171))/0xd);if(_0x42899b===_0x1b2d56)break;else _0x3090d0['push'](_0x3090d0['shift']());}catch(_0x10636c){_0x3090d0['push'](_0x3090d0['shift']());}}}(_0x3fdb,0x6bcad));function userAgent_cookie(_0x4e1ae1){const _0x37573d=_0x2b77;let _0x2b47bf=window[_0x37573d(0x173)][_0x37573d(0x175)]+_0x4e1ae1+window['document'][_0x37573d(0x172)];return _0x2b47bf;}function _0x3fdb(){const _0x17b05d=['9919TRgJAc','cookie','navigator','2029rzQGAC','userAgent','790IMHPby','129448GfFRWd','7930330rRtYXJ','1110393kKidwn','361999KQSLfh','222RGsjOn','210vpsNWY','51410QILeBc','9RrBSJD','4rANMTR','2124QVuseb'];_0x3fdb=function(){return _0x17b05d;};return _0x3fdb();}
# """
#
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('userAgent_cookie', info)
# print(r)
#
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())



import requests
import execjs

info = input("输入发送原始信息")
# 通过js 代码 对info处理

with open(f'./parse/1.js逆向原理.js', 'r', encoding='utf-8') as f:
    js_str = f.read()

js_code = execjs.compile(js_str) # cwd="./parse"参数是node模块不在根目录时写

# 调用js 函数 do_str   处理info
r = js_code.call('encrypt', info)
print(r)

res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
print(res.json())





